package com.xmkj.bearuser.membercenter.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.common.retrofit.bean.CollectionBean;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.bearuser.R;
import com.xmkj.bearuser.pk.GoodsDetailsActivity;

import java.util.List;

public class CollectionAdapter extends CommonAdapter<CollectionBean> {
    public CollectionAdapter(Context context, List<CollectionBean> data) {
        super(context, data);
    }

    @Override
    protected void convert(ViewHolder holder, final CollectionBean item, int position) {
        holder.setOnClickListener(R.id.btn_delete, new OnItemChildClickListener());
        holder.setImageStr(R.id.iv_img,item.pic_url);
        holder.setText(R.id.tv_name,item.goods_name);
        holder.setText(R.id.tv_sale,item.sales_volume);
        holder.setText(R.id.tv_price,item.goods_price);
        holder.getParentView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, GoodsDetailsActivity.class);
                intent.putExtra(GoodsDetailsActivity.ID,item.gid+"");
                intent.putExtra(GoodsDetailsActivity.TYPE,item.goods_name);
                mContext.startActivity(intent);
            }
        });
    }

    @Override
    protected int getItemViewLayoutId(int position, CollectionBean item) {
        return R.layout.item_collections;
    }
}
